<?php

namespace Xrfg\Api\Trading\Spot\Resources;

use App\Http\Resources\Resource;
use Xrfg\Core\Trading\Spot\Models\Order;

class OrderShowResource extends Resource
{
    public function toArray($request)
    {
        /* @var Order $this */
        return [
            'id' => $this->id,
            'symbol' => $this->symbol,
            'side' => $this->side,
            'price' => $this->price,
            'number' => $this->number,
            'deal_number' => $this->deal_number,
            'total' => $this->total,
            'status' => $this->status,
            'created_at' => $this->created_at->toDateTimeString(),
            'trades' => TradeResource::collection($this->buyTrades->merge($this->sellTrades)),
        ];
    }
}
